 package pt.isel.lercm.projectmanager.spring.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import pt.isel.lercm.projectmanager.spring.dao.UserDAO;
import pt.isel.lercm.projectmanager.spring.model.User;

@Service("UserService")
@Transactional(readOnly = true)
public class UserService implements IUserService{
	
	@Autowired
	UserDAO userDao;
	
	public UserDAO getUserDao() {
		return userDao;
	}

	public void setUserDao(UserDAO userDao) {
		this.userDao = userDao;
	}

	@Transactional(readOnly = false)
	@Override
	public void add(User user) {
		getUserDao().addObject(user);
	}

	@Transactional(readOnly = false)
	@Override
	public void update(User user){
		getUserDao().updateObject(user);
	}
	
	@Transactional(readOnly = false)
	@Override
	public void delete(User user){
		getUserDao().deleteObject(user);
	}
	
	@Override
	public User getById(int id){
		return getUserDao().getByid(id);
	}
	
	@Override
	public List<User> getAll(){
		return getUserDao().getAll();
	}
}
